const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            blue_plate: [],
            city: [],
            childDataForm1: [],
            exchange_address: []
        };
    },
    mounted() {
        this.getCategory();
    },
    watch: {
        'dataForm.Article_SerialNumber'(val) {
            if (this.action == 'Modify') {
                this.changeVillage([this.dataForm.VillageNumber.substring(0, 9)])
            }
        },
    },
    methods: {
        getCategory() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/clientOperation/getDistrictTree`,
                type: "GET",
                data: {
                    DistrictCode: "232723"
                },
                success: (data) => {
                    this.city = data[0].children;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                method: "post",
                data: {
                    SQLSerialNumber: 't_article_exchange_address',
                    Condition: window.btoa(unescape(encodeURIComponent("%%"))),
                    ExtensionCondition: '',
                },
                success: (data) => {
                    data.forEach(item => {
                        item.Address = item.Province + item.City + item.County + item.Town + item.Village + item.Detailed_Address
                    })
                    this.exchange_address = data;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
            })
        },
        changeExchange(val){
            let obj = this.exchange_address.filter(i=>i.Article_Exchange_SerialNumber == val)[0];
            if (obj) {
                this.dataForm.Blue_Plate_SerialNumber = obj.Blue_Plate_SerialNumber;
                this.dataForm.VillageNumber = obj.VillageNumber;
            }
        },
        changeVillage(val) {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                method: "post",
                data: {
                    SQLSerialNumber: 'f_blue_plate_information',
                    Condition: '',
                    ExtensionCondition: window.btoa(unescape(encodeURIComponent("AND blue_plate_information.Village_SerialNumber LIKE '%" + val[0] + "%'"))),
                },
                success: (data) => {
                    this.blue_plate = data;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
            })
        },
        changeBlue_Plate(val) {
            if (val) {
                let obj = this.blue_plate.filter(i => i.Blue_Plate_SerialNumber == val)[0];
                if (obj) {
                    this.dataForm.Detailed_Address = obj.Address;
                }
            }
        },
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-cascader', ylCascader)
app.component('yl-text-editor', ylTextEditor);
app.component('yl-select', ylSelect)
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
